tests: move non-test binaries from here to ../tools
authorØyvind Kolås <pippin@gimp.org>
Mon, 25 Sep 2017 19:06:46 +0000 (21:06 +0200)
committerØyvind Kolås <pippin@gimp.org>
Mon, 25 Sep 2017 19:06:46 +0000 (21:06 +0200)
13 files changed:
docs/Makefile.am
tests/Makefile.am
tests/babl-html-dump.c [deleted file]
tests/babl_fish_path_fitness.c [deleted file]
tests/conversions.c [deleted file]
tests/formats.c [deleted file]
tests/introspect.c [deleted file]
tools/Makefile.am
tools/babl-html-dump.c [new file with mode: 0644]
tools/babl_fish_path_fitness.c [new file with mode: 0644]
tools/conversions.c [new file with mode: 0644]
tools/formats.c [new file with mode: 0644]
tools/introspect.c [new file with mode: 0644]

index e53d9a9d0dbb4a14ada95fb70d67fee72d9e1654..e612c7c64f84a7eb54f11531862c0c1e35e677a3 100644 (file)
@@ -1,7 +1,7 @@
 # programs used for doc creation
-babl_fish_path_dhtml   = $(top_builddir)/tests/babl_fish_path_dhtml$(EXEEXT)
-babl_fish_path_fitness = $(top_builddir)/tests/babl_fish_path_fitness$(EXEEXT)
-babl_html_dump         = $(top_builddir)/tests/babl-html-dump$(EXEEXT)
+babl_fish_path_dhtml   = $(top_builddir)/tools/babl_fish_path_dhtml$(EXEEXT)
+babl_fish_path_fitness = $(top_builddir)/tools/babl_fish_path_fitness$(EXEEXT)
+babl_html_dump         = $(top_builddir)/tools/babl-html-dump$(EXEEXT)
 
 .SILENT:
 SUBDIRS=      graphics
index ac46eb756a0f4c2226366498ad5c4104a048e824..5c3706cf0c86ee9f8bd6b834fd70ccdecbde2866 100644 (file)
@@ -44,9 +44,4 @@ LDADD = $(top_builddir)/babl/libbabl-@BABL_API_VERSION@.la \
 EXTRA_DIST=common.inc
 
 noinst_PROGRAMS =              \
-       introspect              \
-       babl_fish_path_fitness  \
-       babl-html-dump          \
-       conversions             \
-       formats                 \
        $(C_TESTS)
diff --git a/tests/babl-html-dump.c b/tests/babl-html-dump.c
deleted file mode 100644 (file)
index 4c01611..0000000
+++ /dev/null
@@ -1,220 +0,0 @@
-/* babl - dynamically extendable universal pixel conversion library.
- * Copyright (C) 2005, Øyvind Kolås.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General
- * Public License along with this library; if not, see
- * <http://www.gnu.org/licenses/>.
- *
- */
-
-#include "config.h"
-#include "babl-internal.h"    /* needed for babl_log */
-
-static void model_html (Babl *babl);
-static void type_html (Babl *babl);
-static void format_html (Babl *babl);
-static void conversion_html (Babl *babl);
-
-static int  each_item (Babl *babl,
-                       void *user_data);
-static int  show_item (Babl *babl,
-                       void *user_data);
-static int  hide_item (Babl *babl,
-                       void *user_data);
-
-
-int
-main (void)
-{
-  babl_init ();
-
-  printf ("<br/><a href='javascript:");
-  printf ("show(\"x_types\");show(\"x_models\");show(\"x_formats\");show(\"x_conversions\");");
-  babl_type_class_for_each (show_item, NULL);
-  babl_model_class_for_each (show_item, NULL);
-  babl_format_class_for_each (show_item, NULL);
-/*  babl_conversion_each (show_item, NULL);*/
-  printf ("'>+</a>");
-
-  printf ("<a href='javascript:");
-  printf ("hide(\"x_types\");hide(\"x_models\");hide(\"x_formats\");hide(\"x_conversions\");");
-  babl_type_class_for_each (hide_item, NULL);
-  babl_model_class_for_each (hide_item, NULL);
-  babl_format_class_for_each (hide_item, NULL);
-  /*babl_conversion_each (hide_item, NULL);*/
-  printf ("'>-</a>");
-
-  printf ("<div class='expander'>");
-  printf ("<div class='expander_title'><a style='font-size:110%%' name='Data-types' href='javascript:toggle_visible(\"x_types\")'>Data types</a></div><div class='expander_content' id='x_types'>\n");
-  babl_type_class_for_each (each_item, NULL);
-  printf ("</div>\n");
-  printf ("</div>\n");
-
-  printf ("<div class='expander'>");
-  printf ("<div class='expander_title'><a style='font-size:110%%' name='Color-models' href='javascript:toggle_visible(\"x_models\")'>Color models</a></div><div class='expander_content' id='x_models'>\n");
-  babl_model_class_for_each (each_item, NULL);
-  printf ("</div>\n");
-  printf ("</div>\n");
-
-
-  printf ("<div class='expander'>");
-  printf ("<div class='expander_title'><a style='font-size:110%%' name='Pixel-formats' href='javascript:toggle_visible(\"x_formats\")'>Pixel formats</a></div><div class='expander_content' id='x_formats'>\n");
-  babl_format_class_for_each (each_item, NULL);
-  printf ("</div>\n");
-  printf ("</div>\n");
-
-/*
-   printf ("<div class='expander'>");
-   printf ("<div class='expander_title'><a style='font-size:110%%' name='Conversions' href='javascript:toggle_visible(\"x_conversions\")'>Conversions</a></div><div class='expander_content' id='x_conversions'>\n");
-   babl_conversion_each (each_item, NULL);
-   printf ("</div>\n");
-   printf ("</div>\n");
- */
-  babl_exit ();
-
-  return 0;
-}
-
-
-static char normalized_buf[512];
-
-static const char *normalize (const char *str)
-{
-  char *s = normalized_buf;
-
-  strcpy (normalized_buf, str);
-
-  while (*s)
-    {
-      if ((*s >= 'a' && *s <= 'z') ||
-          (*s >= 'A' && *s <= 'Z') ||
-          (*s >= '0' && *s <= '9'))
-        {
-        }
-      else
-        {
-          *s = '_';
-        }
-      s++;
-    }
-  return normalized_buf;
-}
-
-
-static int
-show_item (Babl *babl,
-           void *user_data)
-{
-  printf ("show(\"x_%s\");", normalize (babl->instance.name));
-  return 0;
-}
-
-
-static int
-hide_item (Babl *babl,
-           void *user_data)
-{
-  printf ("hide(\"x_%s\");", normalize (babl->instance.name));
-  return 0;
-}
-
-static int
-each_item (Babl *babl,
-           void *user_data)
-{
-  printf ("<div class='expander'>");
-  printf ("<div class='expander_title'><a href='javascript:toggle_visible(\"x_%s\")'>%s</a></div>\n",
-          normalize (babl->instance.name), babl->instance.name);
-  printf ("<div class='expander_content' id='x_%s'>\n",
-          normalize (babl->instance.name));
-
-
-  switch (babl->class_type)
-    {
-      case BABL_TYPE:
-        type_html (babl);
-        break;
-
-      case BABL_MODEL:
-        model_html (babl);
-        break;
-
-      case BABL_FORMAT:
-        format_html (babl);
-        break;
-
-      case BABL_CONVERSION:
-      case BABL_CONVERSION_LINEAR:
-      case BABL_CONVERSION_PLANE:
-      case BABL_CONVERSION_PLANAR:
-        conversion_html (babl);
-        break;
-
-      default:
-        break;
-    }
-
-  printf ("</div>\n");
-  printf ("</div>\n");
-  return 0;
-}
-
-static void
-model_html (Babl *babl)
-{
-  int i;
-
-  printf ("<dl>");
-  printf ("<dt>components</dt><dd><table class='nopad'>");
-
-  for (i = 0; i < babl->model.components; i++)
-    {
-      printf ("<tr><td class='type'>%s</td></tr>",
-              BABL (babl->model.component[i])->instance.name);
-    }
-  printf ("</table></dd></dl>");
-}
-
-static void
-type_html (Babl *babl)
-{
-  printf ("<dl><dt>bits</dt><dd>%i</dd>", babl->type.bits);
-  printf ("<dt>bytes</dt><dd>%i</dd></dl>", babl->type.bits / 8);
-}
-
-
-static void
-conversion_html (Babl *babl)
-{
-  printf ("\n");
-}
-
-static void
-format_html (Babl *babl)
-{
-  int i;
-
-  printf ("<dl>");
-  printf ("<dt>bytes/pixel</dt><dd>%i</dd>", babl->format.bytes_per_pixel);
-  printf ("<dt>model</dt><dd>%s</dd>", BABL (babl->format.model)->instance.name);
-  printf ("<dt>components</dt><dd><table class='nopad'>");
-
-  for (i = 0; i < babl->format.components; i++)
-    {
-      printf ("<tr><td class='type'>%s</td><td class='component'>%s</td></tr>",
-              BABL (babl->format.type[i])->instance.name,
-              BABL (babl->format.component[i])->instance.name);
-    }
-  printf ("</table></dd></dl>");
-}
-
diff --git a/tests/babl_fish_path_fitness.c b/tests/babl_fish_path_fitness.c
deleted file mode 100644 (file)
index 93e1287..0000000
+++ /dev/null
@@ -1,147 +0,0 @@
-/* perform a symmetricality of conversion test on a set of randomized
- * RGBA data */
-
-#include "config.h"
-#include <stdlib.h>
-#include <math.h>
-#include "babl-internal.h"
-
-#ifndef HAVE_SRANDOM
-#define srandom srand
-#define random  rand
-#endif
-
-#define pixels    1024
-int           total_length = 0;
-int           total_cost   = 0;
-int           total        = 0;
-int           ok           = 0;
-
-static double test[pixels * 4];
-
-static void
-test_init (void)
-{
-  int i;
-
-  for (i = 0; i < pixels * 4; i++)
-    test [i] = (double) random () / RAND_MAX;
-}
-
-static int   qux = 0;
-
-static char *utf8_bar[] = { " ", "·", "▁", "▂", "▃", "▄", "▅", "▆", "▇", "█" };
-/*
-static char *utf8_bar[]=  {"!","▁","▃","▅","▇","█","!","!","!"};
-static char *utf8_bar[]={"·", "█", "▇", "▆", "▅", "▄", "▃", "▂", "▁", };
-static char *utf8_bar[]={" ","1","2","3","4","5","6","7","8"};
-*/
-
-static int destination_each (Babl *babl,
-                             void *userdata)
-{
-  Babl *source      = userdata;
-  Babl *destination = babl;
-
-  qux++;
-  if (qux % babl_formats_count () == qux / babl_formats_count ())
-    printf (" ");
-  else
-    {
-      Babl *temp = babl_fish_path (source, destination);
-
-      if (temp)
-        {
-          printf ("%s", utf8_bar[babl_list_size (temp->fish_path.conversion_list)]);
-          total_length += babl_list_size (temp->fish_path.conversion_list);
-          total_cost   += temp->fish_path.cost;
-          ok++;
-          total++;
-        }
-      else
-        {
-          printf (" ");
-          total++;
-        }
-    }
-  return 0;
-}
-
-static int source_no = 0;
-
-static int source_each (Babl *babl,
-                        void *userdata)
-{
-  babl_format_class_for_each (destination_each, babl);
-  printf ("──%2i %s\n", source_no++, babl->instance.name);
-  return 0;
-}
-
-int main (void)
-{
-  babl_init ();
-  test_init ();
-
-  babl_set_extender (babl_extension_quiet_log ());
-  babl_format_class_for_each (source_each, NULL);
-
-  {
-    int i;
-
-    for (i = 0; i < babl_formats_count (); i++)
-      printf ("|");
-
-    printf ("\n");
-
-    for (i = 0; i < babl_formats_count (); i++)
-      {
-        if (i / 100 == 0)
-          printf ("|");
-        else
-          printf ("%i", (i / 100) % 10);
-      }
-
-    printf ("\n");
-
-    for (i = 0; i < babl_formats_count (); i++)
-      {
-        if (i / 10 == 0)
-          printf ("|");
-        else
-          printf ("%i", (i / 10) % 10);
-      }
-
-    printf ("\n");
-
-    /*
-    for (i = 0; i < babl_formats_count (); i++)
-      printf ("│");
-
-    printf ("\n");
-
-    for (i = 0; i < babl_formats_count (); i++)
-      {
-        if (i / 10 == 0)
-          printf ("│");
-        else
-          printf ("%i", (i / 10) % 10);
-      }
-
-    printf ("\n");
-    */
-
-    for (i = 0; i < babl_formats_count (); i++)
-      printf ("%i", (i) % 10);
-
-    printf ("\n");
-  }
-
-  printf ("total length: %i\n", total_length);
-  printf ("total cost  : %i\n", total_cost);
-  /*printf ("ok / total : %i %i %f\n", ok, total, (1.0*ok) / total);
-   */
-
-  babl_exit ();
-
-  return 0;
-}
diff --git a/tests/conversions.c b/tests/conversions.c
deleted file mode 100644 (file)
index 946bfb9..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-/* perform a symmetricality of conversion test on a set of randomized
- * RGBA data */
-
-#include "config.h"
-#include <stdlib.h>
-#include <math.h>
-#include "babl-internal.h"
-
-#define ERROR_TOLERANCE    0.5
-
-static int OK = 1;
-
-static int
-each_conversion (Babl *babl,
-                 void *userdata)
-{
-  double error = babl->conversion.error;
-
-  if (error >= ERROR_TOLERANCE)
-    {
-      babl_log ("%s\terror:%f", babl->instance.name, error);
-      OK = 0;
-    }
-  return 0;
-}
-
-int main (void)
-{
-  babl_init ();
-
-  babl_set_extender (babl_extension_quiet_log ());
-  babl_conversion_class_for_each (each_conversion, NULL);
-
-  babl_exit ();
-
-  return !OK;
-}
diff --git a/tests/formats.c b/tests/formats.c
deleted file mode 100644 (file)
index 8f481bb..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-/* perform a symmetricality of conversion test on a set of randomized
- * RGBA data */
-
-#include "config.h"
-#include <stdlib.h>
-#include <math.h>
-#include "babl-internal.h"
-
-
-static int format_check (Babl *babl,
-                         void *userdata)
-{
-  babl_log ("%s\tloss: %f", babl->instance.name, babl->format.loss);
-  return 0;
-}
-
-int main (void)
-{
-  babl_init ();
-
-  babl_set_extender (babl_extension_quiet_log ());
-  babl_format_class_for_each (format_check, (void *) 1);
-
-  babl_exit ();
-
-  return 0;
-}
diff --git a/tests/introspect.c b/tests/introspect.c
deleted file mode 100644 (file)
index b52ed9f..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-/* babl - dynamically extendable universal pixel conversion library.
- * Copyright (C) 2005, Øyvind Kolås.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General
- * Public License along with this library; if not, see
- * <http://www.gnu.org/licenses/>.
- */
-
-#include "config.h"
-#include "babl-internal.h"
-
-int
-main (int    argc,
-      char **argv)
-{
-  babl_init ();
-  babl_introspect (NULL);
-  babl_exit ();
-  return 0;
-}
index 7adce8884dee7909151d722fc43415aa00a04134..0872763fd39d05dbd99114ae8f56e6e9801452f0 100644 (file)
@@ -3,7 +3,17 @@ AM_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/babl
 LDADD = $(top_builddir)/babl/libbabl-@BABL_API_VERSION@.la \
        $(MATH_LIB) $(THREAD_LIB)
 
-noinst_PROGRAMS = babl-verify babl-benchmark babl-icc-dump babl-icc-rewrite trc-validator
+noinst_PROGRAMS =              \
+       babl-verify             \
+       babl-benchmark          \
+       babl-icc-dump           \
+       babl-icc-rewrite        \
+       trc-validator           \
+       introspect              \
+       babl_fish_path_fitness  \
+       babl-html-dump          \
+       conversions             \
+       formats 
 if HAVE_SRANDOM
 noinst_PROGRAMS +=             \
        babl-gen-test-pixels
diff --git a/tools/babl-html-dump.c b/tools/babl-html-dump.c
new file mode 100644 (file)
index 0000000..4c01611
--- /dev/null
@@ -0,0 +1,220 @@
+/* babl - dynamically extendable universal pixel conversion library.
+ * Copyright (C) 2005, Øyvind Kolås.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "config.h"
+#include "babl-internal.h"    /* needed for babl_log */
+
+static void model_html (Babl *babl);
+static void type_html (Babl *babl);
+static void format_html (Babl *babl);
+static void conversion_html (Babl *babl);
+
+static int  each_item (Babl *babl,
+                       void *user_data);
+static int  show_item (Babl *babl,
+                       void *user_data);
+static int  hide_item (Babl *babl,
+                       void *user_data);
+
+
+int
+main (void)
+{
+  babl_init ();
+
+  printf ("<br/><a href='javascript:");
+  printf ("show(\"x_types\");show(\"x_models\");show(\"x_formats\");show(\"x_conversions\");");
+  babl_type_class_for_each (show_item, NULL);
+  babl_model_class_for_each (show_item, NULL);
+  babl_format_class_for_each (show_item, NULL);
+/*  babl_conversion_each (show_item, NULL);*/
+  printf ("'>+</a>");
+
+  printf ("<a href='javascript:");
+  printf ("hide(\"x_types\");hide(\"x_models\");hide(\"x_formats\");hide(\"x_conversions\");");
+  babl_type_class_for_each (hide_item, NULL);
+  babl_model_class_for_each (hide_item, NULL);
+  babl_format_class_for_each (hide_item, NULL);
+  /*babl_conversion_each (hide_item, NULL);*/
+  printf ("'>-</a>");
+
+  printf ("<div class='expander'>");
+  printf ("<div class='expander_title'><a style='font-size:110%%' name='Data-types' href='javascript:toggle_visible(\"x_types\")'>Data types</a></div><div class='expander_content' id='x_types'>\n");
+  babl_type_class_for_each (each_item, NULL);
+  printf ("</div>\n");
+  printf ("</div>\n");
+
+  printf ("<div class='expander'>");
+  printf ("<div class='expander_title'><a style='font-size:110%%' name='Color-models' href='javascript:toggle_visible(\"x_models\")'>Color models</a></div><div class='expander_content' id='x_models'>\n");
+  babl_model_class_for_each (each_item, NULL);
+  printf ("</div>\n");
+  printf ("</div>\n");
+
+
+  printf ("<div class='expander'>");
+  printf ("<div class='expander_title'><a style='font-size:110%%' name='Pixel-formats' href='javascript:toggle_visible(\"x_formats\")'>Pixel formats</a></div><div class='expander_content' id='x_formats'>\n");
+  babl_format_class_for_each (each_item, NULL);
+  printf ("</div>\n");
+  printf ("</div>\n");
+
+/*
+   printf ("<div class='expander'>");
+   printf ("<div class='expander_title'><a style='font-size:110%%' name='Conversions' href='javascript:toggle_visible(\"x_conversions\")'>Conversions</a></div><div class='expander_content' id='x_conversions'>\n");
+   babl_conversion_each (each_item, NULL);
+   printf ("</div>\n");
+   printf ("</div>\n");
+ */
+  babl_exit ();
+
+  return 0;
+}
+
+
+static char normalized_buf[512];
+
+static const char *normalize (const char *str)
+{
+  char *s = normalized_buf;
+
+  strcpy (normalized_buf, str);
+
+  while (*s)
+    {
+      if ((*s >= 'a' && *s <= 'z') ||
+          (*s >= 'A' && *s <= 'Z') ||
+          (*s >= '0' && *s <= '9'))
+        {
+        }
+      else
+        {
+          *s = '_';
+        }
+      s++;
+    }
+  return normalized_buf;
+}
+
+
+static int
+show_item (Babl *babl,
+           void *user_data)
+{
+  printf ("show(\"x_%s\");", normalize (babl->instance.name));
+  return 0;
+}
+
+
+static int
+hide_item (Babl *babl,
+           void *user_data)
+{
+  printf ("hide(\"x_%s\");", normalize (babl->instance.name));
+  return 0;
+}
+
+static int
+each_item (Babl *babl,
+           void *user_data)
+{
+  printf ("<div class='expander'>");
+  printf ("<div class='expander_title'><a href='javascript:toggle_visible(\"x_%s\")'>%s</a></div>\n",
+          normalize (babl->instance.name), babl->instance.name);
+  printf ("<div class='expander_content' id='x_%s'>\n",
+          normalize (babl->instance.name));
+
+
+  switch (babl->class_type)
+    {
+      case BABL_TYPE:
+        type_html (babl);
+        break;
+
+      case BABL_MODEL:
+        model_html (babl);
+        break;
+
+      case BABL_FORMAT:
+        format_html (babl);
+        break;
+
+      case BABL_CONVERSION:
+      case BABL_CONVERSION_LINEAR:
+      case BABL_CONVERSION_PLANE:
+      case BABL_CONVERSION_PLANAR:
+        conversion_html (babl);
+        break;
+
+      default:
+        break;
+    }
+
+  printf ("</div>\n");
+  printf ("</div>\n");
+  return 0;
+}
+
+static void
+model_html (Babl *babl)
+{
+  int i;
+
+  printf ("<dl>");
+  printf ("<dt>components</dt><dd><table class='nopad'>");
+
+  for (i = 0; i < babl->model.components; i++)
+    {
+      printf ("<tr><td class='type'>%s</td></tr>",
+              BABL (babl->model.component[i])->instance.name);
+    }
+  printf ("</table></dd></dl>");
+}
+
+static void
+type_html (Babl *babl)
+{
+  printf ("<dl><dt>bits</dt><dd>%i</dd>", babl->type.bits);
+  printf ("<dt>bytes</dt><dd>%i</dd></dl>", babl->type.bits / 8);
+}
+
+
+static void
+conversion_html (Babl *babl)
+{
+  printf ("\n");
+}
+
+static void
+format_html (Babl *babl)
+{
+  int i;
+
+  printf ("<dl>");
+  printf ("<dt>bytes/pixel</dt><dd>%i</dd>", babl->format.bytes_per_pixel);
+  printf ("<dt>model</dt><dd>%s</dd>", BABL (babl->format.model)->instance.name);
+  printf ("<dt>components</dt><dd><table class='nopad'>");
+
+  for (i = 0; i < babl->format.components; i++)
+    {
+      printf ("<tr><td class='type'>%s</td><td class='component'>%s</td></tr>",
+              BABL (babl->format.type[i])->instance.name,
+              BABL (babl->format.component[i])->instance.name);
+    }
+  printf ("</table></dd></dl>");
+}
+
diff --git a/tools/babl_fish_path_fitness.c b/tools/babl_fish_path_fitness.c
new file mode 100644 (file)
index 0000000..93e1287
--- /dev/null
@@ -0,0 +1,147 @@
+/* perform a symmetricality of conversion test on a set of randomized
+ * RGBA data */
+
+#include "config.h"
+#include <stdlib.h>
+#include <math.h>
+#include "babl-internal.h"
+
+#ifndef HAVE_SRANDOM
+#define srandom srand
+#define random  rand
+#endif
+
+#define pixels    1024
+int           total_length = 0;
+int           total_cost   = 0;
+int           total        = 0;
+int           ok           = 0;
+
+static double test[pixels * 4];
+
+static void
+test_init (void)
+{
+  int i;
+
+  for (i = 0; i < pixels * 4; i++)
+    test [i] = (double) random () / RAND_MAX;
+}
+
+static int   qux = 0;
+
+static char *utf8_bar[] = { " ", "·", "▁", "▂", "▃", "▄", "▅", "▆", "▇", "█" };
+/*
+static char *utf8_bar[]=  {"!","▁","▃","▅","▇","█","!","!","!"};
+static char *utf8_bar[]={"·", "█", "▇", "▆", "▅", "▄", "▃", "▂", "▁", };
+static char *utf8_bar[]={" ","1","2","3","4","5","6","7","8"};
+*/
+
+static int destination_each (Babl *babl,
+                             void *userdata)
+{
+  Babl *source      = userdata;
+  Babl *destination = babl;
+
+  qux++;
+  if (qux % babl_formats_count () == qux / babl_formats_count ())
+    printf (" ");
+  else
+    {
+      Babl *temp = babl_fish_path (source, destination);
+
+      if (temp)
+        {
+          printf ("%s", utf8_bar[babl_list_size (temp->fish_path.conversion_list)]);
+          total_length += babl_list_size (temp->fish_path.conversion_list);
+          total_cost   += temp->fish_path.cost;
+          ok++;
+          total++;
+        }
+      else
+        {
+          printf (" ");
+          total++;
+        }
+    }
+  return 0;
+}
+
+static int source_no = 0;
+
+static int source_each (Babl *babl,
+                        void *userdata)
+{
+  babl_format_class_for_each (destination_each, babl);
+  printf ("──%2i %s\n", source_no++, babl->instance.name);
+  return 0;
+}
+
+int main (void)
+{
+  babl_init ();
+  test_init ();
+
+  babl_set_extender (babl_extension_quiet_log ());
+  babl_format_class_for_each (source_each, NULL);
+
+  {
+    int i;
+
+    for (i = 0; i < babl_formats_count (); i++)
+      printf ("|");
+
+    printf ("\n");
+
+    for (i = 0; i < babl_formats_count (); i++)
+      {
+        if (i / 100 == 0)
+          printf ("|");
+        else
+          printf ("%i", (i / 100) % 10);
+      }
+
+    printf ("\n");
+
+    for (i = 0; i < babl_formats_count (); i++)
+      {
+        if (i / 10 == 0)
+          printf ("|");
+        else
+          printf ("%i", (i / 10) % 10);
+      }
+
+    printf ("\n");
+
+    /*
+    for (i = 0; i < babl_formats_count (); i++)
+      printf ("│");
+
+    printf ("\n");
+
+    for (i = 0; i < babl_formats_count (); i++)
+      {
+        if (i / 10 == 0)
+          printf ("│");
+        else
+          printf ("%i", (i / 10) % 10);
+      }
+
+    printf ("\n");
+    */
+
+    for (i = 0; i < babl_formats_count (); i++)
+      printf ("%i", (i) % 10);
+
+    printf ("\n");
+  }
+
+  printf ("total length: %i\n", total_length);
+  printf ("total cost  : %i\n", total_cost);
+  /*printf ("ok / total : %i %i %f\n", ok, total, (1.0*ok) / total);
+   */
+
+  babl_exit ();
+
+  return 0;
+}
diff --git a/tools/conversions.c b/tools/conversions.c
new file mode 100644 (file)
index 0000000..946bfb9
--- /dev/null
@@ -0,0 +1,37 @@
+/* perform a symmetricality of conversion test on a set of randomized
+ * RGBA data */
+
+#include "config.h"
+#include <stdlib.h>
+#include <math.h>
+#include "babl-internal.h"
+
+#define ERROR_TOLERANCE    0.5
+
+static int OK = 1;
+
+static int
+each_conversion (Babl *babl,
+                 void *userdata)
+{
+  double error = babl->conversion.error;
+
+  if (error >= ERROR_TOLERANCE)
+    {
+      babl_log ("%s\terror:%f", babl->instance.name, error);
+      OK = 0;
+    }
+  return 0;
+}
+
+int main (void)
+{
+  babl_init ();
+
+  babl_set_extender (babl_extension_quiet_log ());
+  babl_conversion_class_for_each (each_conversion, NULL);
+
+  babl_exit ();
+
+  return !OK;
+}
diff --git a/tools/formats.c b/tools/formats.c
new file mode 100644 (file)
index 0000000..8f481bb
--- /dev/null
@@ -0,0 +1,27 @@
+/* perform a symmetricality of conversion test on a set of randomized
+ * RGBA data */
+
+#include "config.h"
+#include <stdlib.h>
+#include <math.h>
+#include "babl-internal.h"
+
+
+static int format_check (Babl *babl,
+                         void *userdata)
+{
+  babl_log ("%s\tloss: %f", babl->instance.name, babl->format.loss);
+  return 0;
+}
+
+int main (void)
+{
+  babl_init ();
+
+  babl_set_extender (babl_extension_quiet_log ());
+  babl_format_class_for_each (format_check, (void *) 1);
+
+  babl_exit ();
+
+  return 0;
+}
diff --git a/tools/introspect.c b/tools/introspect.c
new file mode 100644 (file)
index 0000000..b52ed9f
--- /dev/null
@@ -0,0 +1,30 @@
+/* babl - dynamically extendable universal pixel conversion library.
+ * Copyright (C) 2005, Øyvind Kolås.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, see
+ * <http://www.gnu.org/licenses/>.
+ */
+
+#include "config.h"
+#include "babl-internal.h"
+
+int
+main (int    argc,
+      char **argv)
+{
+  babl_init ();
+  babl_introspect (NULL);
+  babl_exit ();
+  return 0;
+}